Skip to content

fix(core): export the Project block in the DBML exporter - #1034

Merged
huydo862003 merged 2 commits into
holistics:masterfrom
mateuscmtropical:fix/dbml-exporter-project
Nov 12, 2026
Merged

huydo862003 merged 2 commits into
holistics:masterfrom
mateuscmtropical:fix/dbml-exporter-project

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Summary

  • DbmlExporter did not write the Project block, so exporting DBML to DBML dropped the project name, database_type and Note. The example from the issue returned an empty string.
  • The exporter now writes the Project block first, with the name (when there is one), database_type and Note. Values are escaped with the existing escapeNote, so the output parses back to the same project. A file without a Project gives the same output as before.
  • SQL importers and the db connectors don't set project info, so their DBML output does not change.

Example:

Project "project_name" {
  database_type: 'PostgreSQL'
  Note: 'Description of the project'
}

Issue

#285

Lasting Changes (Technical)

  • Added DbmlExporter.exportProject.
  • The table_group_settings exporter fixture has a project (name: "a", database_type: "aaa'hehe"), so its expected output now starts with the Project block.
  • Not covered here: the JSON from exporter.export(..., 'json') is the normalized model, which importer.import(..., 'json') can't read back, so that path still fails before reaching the exporter. Passing the normalized JSON to ModelExporter.export(..., 'dbml') now keeps the project.

Checklist

  • Documentation (if necessary)
  • Updated dbml-homepage/static/llms.txt (if docs/features changed)
  • Lint Checks Passed
  • Unit Tests Passed
  • Coverage Tests Passed
  • Integration Tests Passed
  • Code Review

Docs and llms.txt don't need changes since the syntax is the same. @dbml/core tests: 454 passed. The new tests and the updated fixture fail without the change. In @dbml/cli, the 4 db2dbml tests fail the same way on master in my environment because they need live databases.

@huydo862003 huydo862003 added the PR: Bug Fix 🐛 A type of pull request used for changelog categories label Nov 12, 2026

@huydo862003 huydo862003 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution

@huydo862003
huydo862003 merged commit a93499a into holistics:master Nov 12, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 A type of pull request used for changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants